package com.backend.controller;


import com.backend.common.AddUser;
import com.backend.common.StudentForm;
import com.backend.common.UserPassword;
import com.backend.config.Result;
import com.backend.entity.Student;
import com.backend.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Api(tags = "学生相关模块",value = "基础业务操作")
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;


    @PostMapping("/registUser")
    public Result registUser(@RequestBody AddUser addUser){
        return userService.registUser(addUser);
    }

    @GetMapping("/getAllAssAction")
    public Result getAllAssAction(@RequestParam("id")String userId){
        return userService.getAllAssAction(userId);
    }

    @GetMapping("/AddAssAction")
    public Result AddAssAction(@RequestParam("userId")String userId,@RequestParam("actionId")String actionId){
        return userService.AddAssAction(userId,actionId);
    }


    @GetMapping("/deleteImageByUserId")
    public Result deleteImageByUserId(@RequestParam("id")String userId){
        return userService.deleteImageByUserId(userId);
    }

    @GetMapping("/getNewAction")
    public Result getNewAction(@RequestParam("userId")String userId){
        return userService.getNewAction(userId);
    }

    @GetMapping("/getUser")
    public Result getUser(@RequestParam("id")String userId){
        return userService.getUser(userId);
    }


    @PostMapping("/login")
    @ApiOperation(value = "用户登录",httpMethod = "POST")
    public Result<Student> Userlogin(@RequestBody StudentForm studentForm){
        return userService.userLogin(studentForm);
    }

    @PostMapping("/updateStudentPassword")
    Result updateStudentPassword(@RequestBody UserPassword userPassword){
            return userService.updateStudentPassword(userPassword);
    }


    @GetMapping("/AddNewAction")
    public Result AddNewAction(@RequestParam("actionId")String actionId,@RequestParam("stuId") String stuId){
        return userService.addNewAction(actionId,stuId);
    };

    @GetMapping("/quitClub")
    public Result quitClub(@RequestParam("assId")String assId,@RequestParam("stuId") String stuId){
        return userService.quitClub(assId,stuId);
    };

    @GetMapping("/queryAllAss")
    @ApiOperation(value = "学生所参加的所有社团",httpMethod = "GET")
    public Result lookUpByAss(@RequestParam("stuId") String stuId){
        return userService.lookUpUserByAss(stuId);
    };


    @GetMapping("/queryActionUser")
    @ApiOperation(value = "活动当前所有的学生",httpMethod = "GET")
    public Result lookUpActionUser(@RequestParam("actionId") String actionId){
        return userService.lookUpActionUser(actionId);
    };
}
